cmake_minimum_required(VERSION 3.5)

if (UNIX AND NOT APPLE)
	set(LINUX TRUE)
endif()

project(SampleOmni)

set(CMAKE_SKIP_RPATH TRUE)

# Detect system bitness
math(EXPR BITNESS "8*${CMAKE_SIZEOF_VOID_P}")

set(SOURCE_FILES ./Source/Main.cpp
                 ./Source/Common.cpp
                 ./Source/WindowsGlyphList4.cpp
                 ./Source/BasicOutput.cpp
                 ./Source/DefaultFont.cpp
                 ./Source/Tilesets.cpp
                 ./Source/Sprites.cpp
                 ./Source/ManualCellsize.cpp
                 ./Source/AutoGenerated.cpp
                 ./Source/MultipleFonts.cpp
                 ./Source/TextAlignment.cpp
                 ./Source/FormattedLog.cpp
                 ./Source/Layers.cpp
                 ./Source/ExtendedBasics.cpp
                 ./Source/ExtendedInterlayer.cpp
                 ./Source/ExtendedSmoothScroll.cpp
                 ./Source/DynamicSprites.cpp
                 ./Source/Speed.cpp
                 ./Source/Keyboard.cpp
                 ./Source/Mouse.cpp
                 ./Source/TextInput.cpp
                 ./Source/InputFiltering.cpp
                 ./Source/WindowResize.cpp
                 ./Source/Pick.cpp)

set(HEADER_FILES ./Source/Common.hpp)

add_executable(SampleOmni ${SOURCE_FILES} ${HEADER_FILES})

set_target_properties(SampleOmni PROPERTIES
	CXX_STANDARD 14
	CXX_STANDARD_REQUIRED TRUE)
target_include_directories(SampleOmni PRIVATE ${CMAKE_SOURCE_DIR}/Terminal/Include/C)

target_link_libraries(SampleOmni BearLibTerminal)

if(MINGW)
	target_link_libraries(SampleOmni -static)
elseif(LINUX)
	target_link_libraries(SampleOmni -Wl,-R. -static-libgcc -static-libstdc++)
endif()

if(WIN32)
	set_target_properties(SampleOmni PROPERTIES WIN32_EXECUTABLE TRUE)
	target_link_libraries(SampleOmni winmm.lib)
endif()

set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/Output/${CMAKE_SYSTEM_NAME}${BITNESS})
set_target_properties(SampleOmni PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
